package com.test01.controller;

import com.test01.bean.Student;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * author: xl
 * time: 2018/5/22 11:22
 * description:
 **/
@Controller
  public class AnnotationController {


    @RequestMapping(value = "/goReg",method = RequestMethod.GET)
    public String goReg(){
         return "reg/reg";
    }

    @RequestMapping(value = "/doReg",method = RequestMethod.POST)
    public String doReg(String name){
        System.out.println(name);
        return "reg/result";
    }

    @RequestMapping(value = "/doUserAdd",method = RequestMethod.POST)
    public ModelAndView doUserAdd(Student student){
        ModelAndView modelAndView = new ModelAndView();
        student.setAge(28);
        student.setId(1);
        modelAndView.addObject("stu", student);
        modelAndView.setViewName("reg/result");
        return modelAndView;
    }






}
